# Integrating with LangServe

[LangServe](https://python.langchain.com/docs/langserve) is a Python framework that helps developers deploy LangChain [runnables and chains](/docs/expression_language/)
as REST APIs.

If you have a deployed LangServe route, you can use the [RemoteRunnable](https://api.js.langchain.com/classes/langchain_runnables_remote.RemoteRunnable.html) class to interact
with it as if it were a local chain. This allows you to more easily call hosted LangServe instances from JavaScript environments (like in the browser on the frontend).

## Setup

You'll need to install or package LangChain core into your frontend:

```bash npm2yarn
npm install @langchain/core
```

If you are calling a LangServe endpoint from the browser, you'll need to make sure your server is returning CORS headers.
You can use FastAPI's built-in middleware for that:

```python
from fastapi.middleware.cors import CORSMiddleware

# Set all CORS enabled origins
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
    expose_headers=["*"],
)
```

## Usage

Then, you can use any of the [supported LCEL interface methods](/docs/expression_language/interface).
Here's an example of how this looks:

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/ecosystem/langsmith.ts";

<CodeBlock language="typescript">{Example}</CodeBlock>

[`streamLog`](/docs/expression_language/interface) is a lower level method for streaming chain intermediate steps as partial JSONPatch chunks.
This method allows for a few extra options as well to only include or exclude certain named steps:

import StreamLogExample from "@examples/ecosystem/langsmith_stream_log.ts";

<CodeBlock language="typescript">{StreamLogExample}</CodeBlock>

### Configuration

You can also pass in options for headers and timeouts into the constructor. These will be used when making incoming requests:

import OptionsExample from "@examples/ecosystem/langsmith_options.ts";

<CodeBlock language="typescript">{OptionsExample}</CodeBlock>
